/*
 * DefaultCurrencyTest.java
 *
 *  
 */
package org.msb.finance.data;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Currency;

import org.junit.Test;

/**
 * 
 * 
 * @author Marc Boudreau
 * 
 */
@SuppressWarnings("nls")
public class DefaultCurrencyTest {

	/**
	 * Test method for {@link DefaultCurrency#DefaultCurrency()}.
	 */
	@Test
	public void testDefaultCurrency() {
		DefaultCurrency dc = new DefaultCurrency();

		assertNotNull(dc);
		assertEquals("CAD", dc.getDefaultCurrencyCode());
	}

	/**
	 * Test method for {@link DefaultCurrency#getDefaultCurrency()} and
	 * {@link DefaultCurrency#setDefaultCurrency(Currency)}.
	 */
	@Test
	public void testGetAndSetDefaultCurrency() {
		assertEquals(Currency.getInstance("USD"), createDefaultCurrencyFor("USD").getDefaultCurrency());
		assertNull(createDefaultCurrencyForNull());
	}

	/**
	 * Test method for {@link DefaultCurrency#getDefaultCurrencyCode()}.
	 */
	@Test
	public void testGetDefaultCurrencyCode() {
		assertEquals("CAD", createDefaultCurrencyFor("CAD").getDefaultCurrencyCode());
		assertEquals("USD", createDefaultCurrencyFor("USD").getDefaultCurrency());
		assertEquals("EUR", createDefaultCurrencyFor("EUR").getDefaultCurrency());
	}

	/**
	 * 
	 * @return
	 */
	private DefaultCurrency createDefaultCurrencyFor(String code) {
		DefaultCurrency dc = new DefaultCurrency();
		dc.setDefaultCurrency(Currency.getInstance(code));

		return dc;
	}

	/**
	 * 
	 * @return
	 */
	private DefaultCurrency createDefaultCurrencyForNull() {
		DefaultCurrency dc = new DefaultCurrency();
		dc.setDefaultCurrency(null);

		return dc;
	}
}
